<?php

namespace App\Models\DylistModels;

use App\Models\ParentModel;
use ClassesWithParents\D;
use DB;
use App\Components\Tools;
use Log;

/**
 * 抖音热门话题model
 * @author puppet
 */
class DyTopic extends ParentModel
{
    /**
     * 与模型关联的数据表。
     *
     * @var string
     */
    protected $table = 'pt_dy_topic_overall';

    /**
     * DB::直接操作的数据库表名
     * @var string
     */
    protected $db_table = 'pt_dy_topic_overall';

    /**
     * 主键 默认id。
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 指定是否模型应该被戳记时间。
     *
     * @var bool
     */
    public $timestamps = false;


    /**
     *    ajax 拉取数据 type 1总榜 2xx榜 怎么查暂时没考虑好
     */
    function getPageData()
    {
        $limit = 50;
        $sql = " select * from $this->table where type=1 ";
        $sql .= " order by effect_value desc limit $limit";
    }

    //插入新增话题数据
    function upTopicto($data)
    {
        foreach ($data as $k => $v) {
            $date = array(
                'rank' => $v['rank'],
                'title' => $v['title'],
                'effect_value' => $v['effect_value'],
                'rank_change' => $v['rank_change'],
                'create_time' => date('Y-m-d H:i:s', time()),
                'update_time' => date('Y-m-d H:i:s', time()),
                'type' => 1,
            );
            DB::table("pt_dy_topic_overall")->insertGetId($date);
        }
    }

}